[Libreoffice-commits] core.git: vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Mon May 19 15:27:26 PDT 2014


 vcl/source/window/resource.cxx |  158 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 158 insertions(+)

New commits:
commit 9626106562b3e11f66e7a07f1b2173f15ec183f6
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Tue May 20 08:26:05 2014 +1000

    vcl: add missing resource.cxx file
    
    Change-Id: I7ab6fe8592845040f9e87f3667c11200735d7d63

diff --git a/vcl/source/window/resource.cxx b/vcl/source/window/resource.cxx
new file mode 100644
index 0000000..4bb5a0a
--- /dev/null
+++ b/vcl/source/window/resource.cxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <tools/rc.h>
+
+#include <vcl/window.hxx>
+#include <vcl/svapp.hxx>
+
+#include "window.h"
+
+static OString ImplAutoHelpID( ResMgr* pResMgr )
+{
+    OString aRet;
+
+    if( pResMgr && Application::IsAutoHelpIdEnabled() )
+        aRet = pResMgr->GetAutoHelpId();
+
+    return aRet;
+}
+
+
+WinBits Window::ImplInitRes( const ResId& rResId )
+{
+    GetRes( rResId );
+
+    char* pRes = (char*)GetClassRes();
+    pRes += 8;
+    sal_uInt32 nStyle = (sal_uInt32)GetLongRes( (void*)pRes );
+    rResId.SetWinBits( nStyle );
+    return nStyle;
+}
+
+WindowResHeader Window::ImplLoadResHeader( const ResId& rResId )
+{
+    WindowResHeader aHeader;
+
+    aHeader.nObjMask = ReadLongRes();
+
+    // we need to calculate auto helpids before the resource gets closed
+    // if the resource  only contains flags, it will be closed before we try to read a help id
+    // so we always create an auto help id that might be overwritten later
+    // HelpId
+    aHeader.aHelpId = ImplAutoHelpID( rResId.GetResMgr() );
+
+    // ResourceStyle
+    aHeader.nRSStyle = ReadLongRes();
+    // WinBits
+    ReadLongRes();
+
+    if( aHeader.nObjMask & WINDOW_HELPID )
+        aHeader.aHelpId = ReadByteStringRes();
+
+    return aHeader;
+}
+
+void Window::ImplLoadRes( const ResId& rResId )
+{
+    WindowResHeader aHeader = ImplLoadResHeader( rResId );
+
+    SetHelpId( aHeader.aHelpId );
+
+    sal_uLong nObjMask = aHeader.nObjMask;
+
+    bool  bPos  = false;
+    bool  bSize = false;
+    Point aPos;
+    Size  aSize;
+
+    if ( nObjMask & (WINDOW_XYMAPMODE | WINDOW_X | WINDOW_Y) )
+    {
+        // use size as per resource
+        MapUnit ePosMap = MAP_PIXEL;
+
+        bPos = true;
+
+        if ( nObjMask & WINDOW_XYMAPMODE )
+            ePosMap = (MapUnit)ReadLongRes();
+        if ( nObjMask & WINDOW_X )
+            aPos.X() = ImplLogicUnitToPixelX( ReadLongRes(), ePosMap );
+        if ( nObjMask & WINDOW_Y )
+            aPos.Y() = ImplLogicUnitToPixelY( ReadLongRes(), ePosMap );
+    }
+
+    if ( nObjMask & (WINDOW_WHMAPMODE | WINDOW_WIDTH | WINDOW_HEIGHT) )
+    {
+        // use size as per resource
+        MapUnit eSizeMap = MAP_PIXEL;
+
+        bSize = true;
+
+        if ( nObjMask & WINDOW_WHMAPMODE )
+            eSizeMap = (MapUnit)ReadLongRes();
+        if ( nObjMask & WINDOW_WIDTH )
+            aSize.Width() = ImplLogicUnitToPixelX( ReadLongRes(), eSizeMap );
+        if ( nObjMask & WINDOW_HEIGHT )
+            aSize.Height() = ImplLogicUnitToPixelY( ReadLongRes(), eSizeMap );
+    }
+
+    sal_uLong nRSStyle = aHeader.nRSStyle;
+
+    // looks bad due to optimization
+    if ( nRSStyle & RSWND_CLIENTSIZE )
+    {
+        if ( bPos )
+            SetPosPixel( aPos );
+        if ( bSize )
+            SetOutputSizePixel( aSize );
+    }
+    else if ( bPos && bSize )
+        SetPosSizePixel( aPos, aSize );
+    else if ( bPos )
+        SetPosPixel( aPos );
+    else if ( bSize )
+        SetSizePixel( aSize );
+
+    if ( nRSStyle & RSWND_DISABLED )
+        Enable( false );
+
+    if ( nObjMask & WINDOW_TEXT )
+        SetText( ReadStringRes() );
+    if ( nObjMask & WINDOW_HELPTEXT )
+    {
+        SetHelpText( ReadStringRes() );
+        mpWindowImpl->mbHelpTextDynamic = true;
+    }
+    if ( nObjMask & WINDOW_QUICKTEXT )
+        SetQuickHelpText( ReadStringRes() );
+    if ( nObjMask & WINDOW_EXTRALONG )
+    {
+        sal_uIntPtr nRes = ReadLongRes();
+        SetData( (void*)nRes );
+    }
+    if ( nObjMask & WINDOW_UNIQUEID )
+        SetUniqueId( ReadByteStringRes() );
+
+    if ( nObjMask & WINDOW_BORDER_STYLE )
+    {
+        sal_uInt16 nBorderStyle = (sal_uInt16)ReadLongRes();
+        SetBorderStyle( nBorderStyle );
+    }
+}
+


More information about the Libreoffice-commits mailing list