LCOV - code coverage report
Current view: top level - starmath/source - ElementsDockingWindow.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 199 353 56.4 %
Date: 2015-06-13 12:38:46 Functions: 29 42 69.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <ElementsDockingWindow.hxx>
      21             : 
      22             : #include <starmath.hrc>
      23             : #include <smmod.hxx>
      24             : #include <view.hxx>
      25             : #include <visitors.hxx>
      26             : 
      27             : #include <svl/stritem.hxx>
      28             : #include <sfx2/dispatch.hxx>
      29             : #include <sfx2/sfxmodelfactory.hxx>
      30             : #include <vcl/settings.hxx>
      31             : 
      32             : typedef tools::SvRef<SmDocShell> SmDocShellRef;
      33             : 
      34         357 : SmElement::SmElement(SmNodePointer pNode, const OUString& aText, const OUString& aHelpText) :
      35             :     mpNode(pNode),
      36             :     maText(aText),
      37         357 :     maHelpText(aHelpText)
      38         357 : {}
      39             : 
      40         680 : SmElement::~SmElement()
      41         680 : {}
      42             : 
      43        1824 : SmNodePointer SmElement::getNode()
      44             : {
      45        1824 :     return mpNode;
      46             : }
      47             : 
      48          34 : SmElementSeparator::SmElementSeparator() :
      49          34 :     SmElement(SmNodePointer(), OUString(), OUString())
      50          34 : {}
      51             : 
      52             : const sal_uInt16 SmElementsControl::aUnaryBinaryOperatorsList[][2] =
      53             : {
      54             :     {RID_PLUSX, RID_PLUSX_HELP}, {RID_MINUSX, RID_MINUSX_HELP},
      55             :     {RID_PLUSMINUSX, RID_PLUSMINUSX_HELP}, {RID_MINUSPLUSX, RID_MINUSPLUSX_HELP},
      56             :     {0xFFFF, 0},
      57             :     {RID_XPLUSY, RID_XPLUSY_HELP}, {RID_XMINUSY, RID_XMINUSY_HELP},
      58             :     {RID_XCDOTY, RID_XCDOTY_HELP}, {RID_XTIMESY, RID_XTIMESY_HELP},
      59             :     {RID_XSYMTIMESY, RID_XSYMTIMESY_HELP}, {RID_XOTIMESY, RID_XOTIMESY_HELP},
      60             :     {RID_XOVERY, RID_XOVERY_HELP},
      61             :     {RID_XDIVY, RID_XDIVY_HELP}, {RID_XSYMDIVIDEY, RID_XSYMDIVIDEY_HELP},
      62             :     {RID_XCIRCY, RID_XCIRCY_HELP}, {RID_XWIDESLASHY, RID_XWIDESLASHY_HELP},
      63             :     {RID_XWIDEBSLASHY, RID_XWIDEBSLASHY_HELP},
      64             :     {0xFFFF, 0},
      65             :     {RID_NEGX, RID_NEGX_HELP}, {RID_XANDY, RID_XANDY_HELP}, {RID_XORY, RID_XORY_HELP},
      66             : };
      67             : 
      68             : const sal_uInt16 SmElementsControl::aRelationsList[][2] =
      69             : {
      70             :     {RID_XEQY, RID_XEQY_HELP}, {RID_XNEQY, RID_XNEQY_HELP}, {RID_XLTY, RID_XLTY_HELP},
      71             :     {RID_XLEY, RID_XLEY_HELP}, {RID_XLESLANTY, RID_XLESLANTY_HELP}, {RID_XGTY, RID_XGTY_HELP},
      72             :     {RID_XGEY, RID_XGEY_HELP}, {RID_XGESLANTY, RID_XGESLANTY_HELP},
      73             :     {RID_XLLY, RID_XLLY_HELP}, {RID_XGGY, RID_XGGY_HELP},
      74             :     {0xFFFF, 0},
      75             :     {RID_XAPPROXY, RID_XAPPROXY_HELP}, {RID_XSIMY, RID_XSIMY_HELP}, {RID_XSIMEQY, RID_XSIMEQY_HELP},
      76             :     {RID_XEQUIVY, RID_XEQUIVY_HELP}, {RID_XPROPY, RID_XPROPY_HELP}, {RID_XPARALLELY, RID_XPARALLELY_HELP},
      77             :     {RID_XORTHOY, RID_XORTHOY_HELP}, {RID_XDIVIDESY, RID_XDIVIDESY_HELP}, {RID_XNDIVIDESY, RID_XNDIVIDESY_HELP},
      78             :     {RID_XTOWARDY, RID_XTOWARDY_HELP},
      79             :     {0xFFFF, 0},
      80             :     {RID_DLARROW, RID_DLARROW_HELP}, {RID_DLRARROW, RID_DLRARROW_HELP}, {RID_DRARROW, RID_DRARROW_HELP},
      81             :     {0xFFFF, 0},
      82             :     {RID_XPRECEDESY, RID_XPRECEDESY_HELP}, {RID_XSUCCEEDSY, RID_XSUCCEEDSY_HELP},
      83             :     {RID_XPRECEDESEQUALY, RID_XPRECEDESEQUALY_HELP}, {RID_XSUCCEEDSEQUALY, RID_XSUCCEEDSEQUALY_HELP},
      84             :     {RID_XPRECEDESEQUIVY, RID_XPRECEDESEQUIVY_HELP}, {RID_XSUCCEEDSEQUIVY, RID_XSUCCEEDSEQUIVY_HELP},
      85             :     {RID_XNOTPRECEDESY, RID_XNOTPRECEDESY_HELP}, {RID_XNOTSUCCEEDSY, RID_XNOTSUCCEEDSY_HELP},
      86             : };
      87             : 
      88             : const sal_uInt16 SmElementsControl::aSetOperations[][2] =
      89             : {
      90             :     {RID_XINY, RID_XINY_HELP}, {RID_XNOTINY, RID_XNOTINY_HELP}, {RID_XOWNSY, RID_XOWNSY_HELP},
      91             :     {0xFFFF, 0},
      92             :     {RID_XINTERSECTIONY, RID_XINTERSECTIONY_HELP}, {RID_XUNIONY, RID_XUNIONY_HELP},
      93             :     {RID_XSETMINUSY, RID_XSETMINUSY_HELP}, {RID_XSLASHY, RID_XSLASHY_HELP},
      94             :     {RID_XSUBSETY, RID_XSUBSETY_HELP}, {RID_XSUBSETEQY, RID_XSUBSETEQY_HELP},
      95             :     {RID_XSUPSETY, RID_XSUPSETY_HELP}, {RID_XSUPSETEQY, RID_XSUPSETEQY_HELP},
      96             :     {RID_XNSUBSETY, RID_XNSUBSETY_HELP}, {RID_XNSUBSETEQY, RID_XNSUBSETEQY_HELP},
      97             :     {RID_XNSUPSETY, RID_XNSUPSETY_HELP}, {RID_XNSUPSETEQY, RID_XNSUPSETEQY_HELP},
      98             :     {0xFFFF, 0},
      99             :     {RID_EMPTYSET, RID_EMPTYSET_HELP}, {RID_ALEPH, RID_ALEPH_HELP}, {RID_SETN, RID_SETN_HELP},
     100             :     {RID_SETZ, RID_SETZ_HELP}, {RID_SETQ, RID_SETQ_HELP}, {RID_SETR, RID_SETR_HELP}, {RID_SETC, RID_SETC_HELP}
     101             : };
     102             : 
     103             : const sal_uInt16 SmElementsControl::aFunctions[][2] =
     104             : {
     105             :     {RID_ABSX, RID_ABSX_HELP}, {RID_FACTX, RID_FACTX_HELP}, {RID_SQRTX, RID_SQRTX_HELP},
     106             :     {RID_NROOTXY, RID_NROOTXY_HELP}, {RID_RSUPX, RID_RSUPX_HELP}, {RID_EX, RID_EX_HELP},
     107             :     {RID_LNX, RID_LNX_HELP}, {RID_EXPX, RID_EXPX_HELP}, {RID_LOGX, RID_LOGX_HELP},
     108             :     {0xFFFF, 0},
     109             :     {RID_SINX, RID_SINX_HELP}, {RID_COSX, RID_COSX_HELP}, {RID_TANX, RID_TANX_HELP}, {RID_COTX, RID_COTX_HELP},
     110             :     {RID_SINHX, RID_SINHX_HELP}, {RID_COSHX, RID_COSHX_HELP}, {RID_TANHX, RID_TANHX_HELP},
     111             :     {RID_COTHX, RID_COTHX_HELP},
     112             :     {0xFFFF, 0},
     113             :     {RID_ARCSINX, RID_ARCSINX_HELP}, {RID_ARCCOSX, RID_ARCCOSX_HELP}, {RID_ARCTANX, RID_ARCTANX_HELP},
     114             :     {RID_ARCCOTX, RID_ARCCOTX_HELP}, {RID_ARSINHX, RID_ARSINHX_HELP}, {RID_ARCOSHX, RID_ARCOSHX_HELP},
     115             :     {RID_ARTANHX, RID_ARTANHX_HELP}, {RID_ARCOTHX, RID_ARCOTHX_HELP}
     116             : };
     117             : 
     118             : const sal_uInt16 SmElementsControl::aOperators[][2] =
     119             : {
     120             :     {RID_LIMX, RID_LIMX_HELP}, {RID_LIM_FROMX, RID_LIM_FROMX_HELP},
     121             :     {RID_LIM_TOX, RID_LIM_TOX_HELP}, {RID_LIM_FROMTOX, RID_LIM_FROMTOX_HELP},
     122             :     {0xFFFF, 0},
     123             :     {RID_SUMX, RID_SUMX_HELP}, {RID_SUM_FROMX, RID_SUM_FROMX_HELP},
     124             :     {RID_SUM_TOX, RID_SUM_TOX_HELP}, {RID_SUM_FROMTOX, RID_SUM_FROMTOX_HELP},
     125             :     {0xFFFF, 0},
     126             :     {RID_PRODX, RID_PRODX_HELP}, {RID_PROD_FROMX, RID_PROD_FROMX_HELP},
     127             :     {RID_PROD_TOX, RID_PROD_TOX_HELP}, {RID_PROD_FROMTOX, RID_PROD_FROMTOX_HELP},
     128             :     {0xFFFF, 0},
     129             :     {RID_COPRODX, RID_COPRODX_HELP}, {RID_COPROD_FROMX, RID_COPROD_FROMX_HELP},
     130             :     {RID_COPROD_TOX, RID_COPROD_TOX_HELP}, {RID_COPROD_FROMTOX, RID_COPROD_FROMTOX_HELP},
     131             :     {0xFFFF, 0},
     132             :     {RID_INTX, RID_INTX_HELP}, {RID_INT_FROMX, RID_INT_FROMX_HELP},
     133             :     {RID_INT_TOX, RID_INT_TOX_HELP}, {RID_INT_FROMTOX, RID_INT_FROMTOX_HELP},
     134             :     {0xFFFF, 0},
     135             :     {RID_IINTX, RID_IINTX_HELP}, {RID_IINT_FROMX, RID_IINT_FROMX_HELP},
     136             :     {RID_IINT_TOX, RID_IINT_TOX_HELP}, {RID_IINT_FROMTOX, RID_IINT_FROMTOX_HELP},
     137             :     {0xFFFF, 0},
     138             :     {RID_IIINTX, RID_IIINTX_HELP}, {RID_IIINT_FROMX, RID_IIINT_FROMX_HELP},
     139             :     {RID_IIINT_TOX, RID_IIINT_TOX_HELP}, {RID_IIINT_FROMTOX, RID_IIINT_FROMTOX_HELP},
     140             :     {0xFFFF, 0},
     141             :     {RID_LINTX, RID_LINTX_HELP}, {RID_LINT_FROMX, RID_LINT_FROMX_HELP},
     142             :     {RID_LINT_TOX, RID_LINT_TOX_HELP}, {RID_LINT_FROMTOX, RID_LINT_FROMTOX_HELP},
     143             :     {0xFFFF, 0},
     144             :     {RID_LLINTX, RID_LINTX_HELP}, {RID_LLINT_FROMX, RID_LLINT_FROMX_HELP},
     145             :     {RID_LLINT_TOX, RID_LINT_TOX_HELP}, {RID_LLINT_FROMTOX, RID_LLINT_FROMTOX_HELP},
     146             :     {0xFFFF, 0},
     147             :     {RID_LLLINTX, RID_LINTX_HELP}, {RID_LLLINT_FROMX, RID_LLLINT_FROMX_HELP},
     148             :     {RID_LLLINT_TOX, RID_LINT_TOX_HELP}, {RID_LLLINT_FROMTOX, RID_LLLINT_FROMTOX_HELP},
     149             : };
     150             : 
     151             : const sal_uInt16 SmElementsControl::aAttributes[][2] =
     152             : {
     153             :     {RID_ACUTEX, RID_ACUTEX_HELP}, {RID_GRAVEX, RID_GRAVEX_HELP}, {RID_BREVEX, RID_BREVEX_HELP},
     154             :     {RID_CIRCLEX, RID_CIRCLEX_HELP}, {RID_DOTX, RID_DOTX_HELP}, {RID_DDOTX, RID_DDOTX_HELP},
     155             :     {RID_DDDOTX, RID_DDDOTX_HELP}, {RID_BARX, RID_BARX_HELP}, {RID_VECX, RID_VECX_HELP},
     156             :     {RID_TILDEX, RID_TILDEX_HELP}, {RID_HATX, RID_HATX_HELP}, {RID_CHECKX, RID_CHECKX_HELP},
     157             :     {0xFFFF, 0},
     158             :     {RID_WIDEVECX, RID_WIDEVECX_HELP}, {RID_WIDETILDEX, RID_WIDETILDEX_HELP}, {RID_WIDEHATX, RID_WIDEHATX_HELP},
     159             :     {RID_OVERLINEX, RID_OVERLINEX_HELP}, {RID_UNDERLINEX, RID_UNDERLINEX_HELP}, {RID_OVERSTRIKEX, RID_OVERSTRIKEX_HELP},
     160             :     {0xFFFF, 0},
     161             :     {RID_PHANTOMX, RID_PHANTOMX_HELP}, {RID_BOLDX, RID_BOLDX_HELP}, {RID_ITALX, RID_ITALX_HELP},
     162             :     {RID_SIZEXY, RID_SIZEXY_HELP}, {RID_FONTXY, RID_FONTXY_HELP},
     163             :     {0xFFFF, 0},
     164             :     {RID_COLORX_BLACK, RID_COLORX_BLACK_HELP}, {RID_COLORX_BLUE, RID_COLORX_BLUE_HELP},
     165             :     {RID_COLORX_GREEN, RID_COLORX_GREEN_HELP}, {RID_COLORX_RED, RID_COLORX_RED_HELP},
     166             :     {RID_COLORX_CYAN, RID_COLORX_CYAN_HELP}, {RID_COLORX_MAGENTA, RID_COLORX_MAGENTA_HELP},
     167             :     {RID_COLORX_YELLOW, RID_COLORX_YELLOW_HELP}, {RID_COLORX_GRAY, RID_COLORX_GRAY_HELP},
     168             :     {RID_COLORX_LIME, RID_COLORX_LIME_HELP}, {RID_COLORX_MAROON, RID_COLORX_MAROON_HELP},
     169             :     {RID_COLORX_NAVY, RID_COLORX_NAVY_HELP}, {RID_COLORX_OLIVE, RID_COLORX_OLIVE_HELP},
     170             :     {RID_COLORX_PURPLE, RID_COLORX_PURPLE_HELP}, {RID_COLORX_SILVER, RID_COLORX_SILVER_HELP},
     171             :     {RID_COLORX_TEAL, RID_COLORX_TEAL_HELP}
     172             : };
     173             : 
     174             : const sal_uInt16 SmElementsControl::aBrackets[][2] =
     175             : {
     176             :     {RID_LRGROUPX, RID_LRGROUPX_HELP},
     177             :     {0xFFFF, 0},
     178             :     {RID_LRPARENTX, RID_LRPARENTX_HELP}, {RID_LRBRACKETX, RID_LRBRACKETX_HELP},
     179             :     {RID_LRDBRACKETX, RID_LRDBRACKETX_HELP}, {RID_LRBRACEX, RID_LRBRACEX_HELP},
     180             :     {RID_LRANGLEX, RID_LRANGLEX_HELP}, {RID_LMRANGLEXY, RID_LMRANGLEXY_HELP},
     181             :     {RID_LRCEILX, RID_LRCEILX_HELP}, {RID_LRFLOORX, RID_LRFLOORX_HELP},
     182             :     {RID_LRLINEX, RID_LRLINEX_HELP}, {RID_LRDLINEX, RID_LRDLINEX_HELP},
     183             :     {0xFFFF, 0},
     184             :     {RID_SLRPARENTX, RID_SLRPARENTX_HELP}, {RID_SLRBRACKETX, RID_SLRBRACKETX_HELP},
     185             :     {RID_SLRDBRACKETX, RID_SLRDBRACKETX_HELP}, {RID_SLRBRACEX, RID_SLRBRACEX_HELP},
     186             :     {RID_SLRANGLEX, RID_SLRANGLEX_HELP}, {RID_SLMRANGLEXY, RID_SLMRANGLEXY_HELP},
     187             :     {RID_SLRCEILX, RID_SLRCEILX_HELP}, {RID_SLRFLOORX, RID_SLRFLOORX_HELP},
     188             :     {RID_SLRLINEX, RID_SLRLINEX_HELP}, {RID_SLRDLINEX, RID_SLRDLINEX_HELP},
     189             :     {0XFFFF, 0},
     190             :     {RID_XOVERBRACEY, RID_XOVERBRACEY_HELP}, {RID_XUNDERBRACEY, RID_XUNDERBRACEY_HELP},
     191             : };
     192             : 
     193             : const sal_uInt16 SmElementsControl::aFormats[][2] =
     194             : {
     195             :     {RID_RSUPX, RID_RSUPX_HELP}, {RID_RSUBX, RID_RSUBX_HELP}, {RID_LSUPX, RID_LSUPX_HELP},
     196             :     {RID_LSUBX, RID_LSUBX_HELP}, {RID_CSUPX, RID_CSUPX_HELP}, {RID_CSUBX, RID_CSUBX_HELP},
     197             :     {0xFFFF, 0},
     198             :     {RID_NEWLINE, RID_NEWLINE_HELP}, {RID_SBLANK, RID_SBLANK_HELP}, {RID_BLANK, RID_BLANK_HELP},
     199             :     {RID_NOSPACE, RID_NOSPACE_HELP},
     200             :     {RID_ALIGNLX, RID_ALIGNLX_HELP}, {RID_ALIGNCX, RID_ALIGNCX_HELP}, {RID_ALIGNRX, RID_ALIGNRX_HELP},
     201             :     {0xFFFF, 0},
     202             :     {RID_BINOMXY, RID_BINOMXY_HELP}, {RID_STACK, RID_STACK_HELP},
     203             :     {RID_MATRIX, RID_MATRIX_HELP},
     204             : };
     205             : 
     206             : const sal_uInt16 SmElementsControl::aOthers[][2] =
     207             : {
     208             :     {RID_INFINITY, RID_INFINITY_HELP}, {RID_PARTIAL, RID_PARTIAL_HELP}, {RID_NABLA, RID_NABLA_HELP},
     209             :     {RID_EXISTS, RID_EXISTS_HELP}, {RID_NOTEXISTS, RID_NOTEXISTS_HELP}, {RID_FORALL, RID_FORALL_HELP},
     210             :     {RID_HBAR, RID_HBAR_HELP}, {RID_LAMBDABAR, RID_LAMBDABAR_HELP}, {RID_RE, RID_RE_HELP},
     211             :     {RID_IM, RID_IM_HELP}, {RID_WP, RID_WP_HELP},
     212             :     {0xFFFF, 0},
     213             :     {RID_LEFTARROW, RID_LEFTARROW_HELP}, {RID_RIGHTARROW, RID_RIGHTARROW_HELP}, {RID_UPARROW, RID_UPARROW_HELP},
     214             :     {RID_DOWNARROW, RID_DOWNARROW_HELP},
     215             :     {0xFFFF, 0},
     216             :     {RID_DOTSLOW, RID_DOTSLOW_HELP}, {RID_DOTSAXIS, RID_DOTSAXIS_HELP}, {RID_DOTSVERT, RID_DOTSVERT_HELP},
     217             :     {RID_DOTSUP, RID_DOTSUP_HELP}, {RID_DOTSDOWN, RID_DOTSDOWN_HELP}
     218             : };
     219             : 
     220          17 : SmElementsControl::SmElementsControl(vcl::Window *pParent)
     221             :     : Control(pParent, WB_TABSTOP)
     222          17 :     , mpDocShell(new SmDocShell(SfxModelFlags::EMBEDDED_OBJECT))
     223             :     , maCurrentSetId(0)
     224             :     , mpCurrentElement(NULL)
     225             :     , mbVerticalMode(true)
     226          34 :     , mxScroll(VclPtr<ScrollBar>::Create(this, WB_VERT))
     227             : {
     228          17 :     SetMapMode( MapMode(MAP_100TH_MM) );
     229          17 :     SetDrawMode( DrawModeFlags::Default );
     230          17 :     SetLayoutMode( TEXT_LAYOUT_DEFAULT );
     231          17 :     SetDigitLanguage( LANGUAGE_ENGLISH );
     232             : 
     233          17 :     maFormat.SetBaseSize(PixelToLogic(Size(0, SmPtsTo100th_mm(12))));
     234             : 
     235          17 :     mxScroll->SetScrollHdl( LINK(this, SmElementsControl, ScrollHdl) );
     236          17 :     mxScroll->Show();
     237          17 : }
     238             : 
     239          51 : SmElementsControl::~SmElementsControl()
     240             : {
     241          17 :     disposeOnce();
     242          34 : }
     243             : 
     244          17 : void SmElementsControl::dispose()
     245             : {
     246          17 :     mpDocShell->DoClose();
     247          17 :     mxScroll.disposeAndClear();
     248          17 :     Control::dispose();
     249          17 : }
     250             : 
     251         119 : void SmElementsControl::setVerticalMode(bool bVerticalMode)
     252             : {
     253         119 :     mbVerticalMode = bVerticalMode;
     254         119 : }
     255             : 
     256          32 : void SmElementsControl::Paint(vcl::RenderContext& rRenderContext, const Rectangle&)
     257             : {
     258          32 :     rRenderContext.Push();
     259             : 
     260          32 :     bool bOldVisibleState = mxScroll->IsVisible();
     261             : 
     262          32 :     sal_Int32 nScrollbarWidth = bOldVisibleState ? GetSettings().GetStyleSettings().GetScrollBarSize() : 0;
     263             : 
     264          32 :     sal_Int32 nControlWidth = rRenderContext.GetOutputSizePixel().Width() - nScrollbarWidth;
     265          32 :     sal_Int32 nControlHeight = rRenderContext.GetOutputSizePixel().Height();
     266             : 
     267          32 :     sal_Int32 boxX = maMaxElementDimensions.Width()  + 10;
     268          32 :     sal_Int32 boxY = maMaxElementDimensions.Height() + 10;
     269             : 
     270          32 :     sal_Int32 x = 0;
     271          32 :     sal_Int32 y = -mxScroll->GetThumbPos();
     272             : 
     273          32 :     sal_Int32 perLine = 0;
     274             : 
     275          32 :     if (mbVerticalMode)
     276           0 :         perLine = nControlHeight / boxY;
     277             :     else
     278          32 :         perLine = nControlWidth / boxX;
     279             : 
     280          32 :     if (perLine <= 0)
     281             :     {
     282           0 :         perLine = 1;
     283             :     }
     284             : 
     285          32 :     if (mbVerticalMode)
     286           0 :         boxY = nControlHeight / perLine;
     287             :     else
     288          32 :         boxX = nControlWidth / perLine;
     289             : 
     290         704 :     for (size_t i = 0; i < maElementList.size() ; i++)
     291             :     {
     292         672 :         SmElement* element = maElementList[i].get();
     293         672 :         if (element->isSeparator())
     294             :         {
     295          64 :             if (mbVerticalMode)
     296             :             {
     297           0 :                 x += boxX;
     298           0 :                 y = 0;
     299             : 
     300           0 :                 Rectangle aSelectionRectangle(x + 5 - 1, y + 5,
     301           0 :                                               x + 5 + 1, nControlHeight - 5);
     302             : 
     303           0 :                 rRenderContext.DrawRect(PixelToLogic(aSelectionRectangle));
     304           0 :                 x += 10;
     305             :             }
     306             :             else
     307             :             {
     308          64 :                 x = 0;
     309          64 :                 y += boxY;
     310             : 
     311         128 :                 Rectangle aSelectionRectangle(x + 5, y + 5 - 1,
     312         192 :                                               nControlWidth - 5, y + 5 + 1);
     313             : 
     314          64 :                 rRenderContext.DrawRect(PixelToLogic(aSelectionRectangle));
     315          64 :                 y += 10;
     316             :             }
     317             :         }
     318             :         else
     319             :         {
     320        1216 :             Size aSizePixel = rRenderContext.LogicToPixel(Size(element->getNode()->GetWidth(),
     321        1824 :                                                                element->getNode()->GetHeight()));
     322         608 :             if (mbVerticalMode)
     323             :             {
     324           0 :                 if (y + boxY > nControlHeight)
     325             :                 {
     326           0 :                     x += boxX;
     327           0 :                     y = 0;
     328             :                 }
     329             :             }
     330             :             else
     331             :             {
     332         608 :                 if ( x + boxX > nControlWidth)
     333             :                 {
     334          64 :                     x = 0;
     335          64 :                     y += boxY;
     336             :                 }
     337             :             }
     338             : 
     339         608 :             if (mpCurrentElement == element)
     340             :             {
     341           0 :                 rRenderContext.Push(PushFlags::FILLCOLOR | PushFlags::LINECOLOR);
     342           0 :                 rRenderContext.SetFillColor(Color(230, 230, 230));
     343           0 :                 rRenderContext.SetLineColor(Color(230, 230, 230));
     344             : 
     345           0 :                 rRenderContext.DrawRect(PixelToLogic(Rectangle(x + 2, y + 2, x + boxX - 2, y + boxY - 2)));
     346           0 :                 rRenderContext.Pop();
     347             :             }
     348             : 
     349         608 :             Point location(x + ((boxX - aSizePixel.Width()) / 2),
     350        1216 :                            y + ((boxY - aSizePixel.Height()) / 2));
     351             : 
     352         608 :             SmDrawingVisitor(rRenderContext, PixelToLogic(location), element->getNode().get());
     353             : 
     354         608 :             element->mBoxLocation = Point(x,y);
     355         608 :             element->mBoxSize = Size(boxX, boxY);
     356             : 
     357         608 :             if (mbVerticalMode)
     358           0 :                 y += boxY;
     359             :             else
     360         608 :                 x += boxX;
     361             :         }
     362             :     }
     363             : 
     364          32 :     sal_Int32 nTotalControlHeight = y + boxY + mxScroll->GetThumbPos();
     365             : 
     366          32 :     if (nTotalControlHeight > GetOutputSizePixel().Height())
     367             :     {
     368           0 :         mxScroll->SetRangeMax(nTotalControlHeight);
     369           0 :         mxScroll->SetPosSizePixel(Point(nControlWidth, 0), Size(nScrollbarWidth, nControlHeight));
     370           0 :         mxScroll->SetVisibleSize(nControlHeight);
     371           0 :         mxScroll->Show();
     372             :     }
     373             :     else
     374             :     {
     375          32 :         mxScroll->SetThumbPos(0);
     376          32 :         mxScroll->Hide();
     377             :     }
     378             : 
     379             :     // If scrollbar visibility changed, we have to go through the
     380             :     // calculation once more, see nScrollbarWidth
     381          32 :     if (bOldVisibleState != mxScroll->IsVisible())
     382          16 :         Invalidate();
     383             : 
     384          32 :     rRenderContext.Pop();
     385          32 : }
     386             : 
     387           0 : void SmElementsControl::MouseMove( const MouseEvent& rMouseEvent )
     388             : {
     389           0 :     mpCurrentElement = NULL;
     390           0 :     OUString tooltip;
     391           0 :     if (Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()))
     392             :     {
     393           0 :         for (size_t i = 0; i < maElementList.size() ; i++)
     394             :         {
     395           0 :             SmElement* element = maElementList[i].get();
     396           0 :             Rectangle rect(element->mBoxLocation, element->mBoxSize);
     397           0 :             if (rect.IsInside(rMouseEvent.GetPosPixel()))
     398             :             {
     399           0 :                 if (mpCurrentElement != element)
     400             :                 {
     401           0 :                     mpCurrentElement = element;
     402           0 :                     Invalidate();
     403           0 :                     tooltip = element->getHelpText();
     404             :                 }
     405             :             }
     406             :         }
     407             :     }
     408             :     else
     409             :     {
     410           0 :         Control::MouseMove (rMouseEvent);
     411             :     }
     412             : 
     413           0 :     SetQuickHelpText(tooltip);
     414           0 : }
     415             : 
     416           0 : void SmElementsControl::MouseButtonDown(const MouseEvent& rMouseEvent)
     417             : {
     418           0 :     GrabFocus();
     419             : 
     420           0 :     if (rMouseEvent.IsLeft() && Rectangle(Point(0, 0), GetOutputSizePixel()).IsInside(rMouseEvent.GetPosPixel()))
     421             :     {
     422           0 :         for (size_t i = 0; i < maElementList.size() ; i++)
     423             :         {
     424           0 :             SmElement* element = maElementList[i].get();
     425           0 :             Rectangle rect(element->mBoxLocation, element->mBoxSize);
     426           0 :             if (rect.IsInside(rMouseEvent.GetPosPixel()))
     427             :             {
     428           0 :                 selectedSignal(element);
     429           0 :                 return;
     430             :             }
     431             :         }
     432             :     }
     433             :     else
     434             :     {
     435           0 :         Control::MouseButtonDown (rMouseEvent);
     436             :     }
     437             : }
     438             : 
     439           0 : IMPL_LINK_NOARG( SmElementsControl, ScrollHdl )
     440             : {
     441           0 :     DoScroll(mxScroll->GetDelta());
     442           0 :     return 0;
     443             : }
     444             : 
     445           0 : void SmElementsControl::DoScroll(long nDelta)
     446             : {
     447           0 :     Point aNewPoint = mxScroll->GetPosPixel();
     448           0 :     Rectangle aRect(Point(), GetOutputSize());
     449           0 :     aRect.Right() -= mxScroll->GetSizePixel().Width();
     450           0 :     Scroll( 0, -nDelta, aRect );
     451           0 :     mxScroll->SetPosPixel(aNewPoint);
     452           0 :     Invalidate();
     453           0 : }
     454             : 
     455          34 : void SmElementsControl::addSeparator()
     456             : {
     457          34 :     SmElementPointer pElement(new SmElementSeparator());
     458          34 :     maElementList.push_back(pElement);
     459          34 : }
     460             : 
     461         323 : void SmElementsControl::addElement(const OUString& aElementVisual, const OUString& aElementSource, const OUString& aHelpText)
     462             : {
     463         323 :     SmNodePointer pNode(SmParser().ParseExpression(aElementVisual));
     464             : 
     465         323 :     pNode->Prepare(maFormat, *mpDocShell);
     466         323 :     pNode->SetSize(Fraction(10,8));
     467         323 :     pNode->Arrange(*this, maFormat);
     468             : 
     469         323 :     Size aSizePixel = LogicToPixel(Size(pNode->GetWidth(), pNode->GetHeight()), MAP_100TH_MM);
     470         323 :     if (aSizePixel.Width() > maMaxElementDimensions.Width()) {
     471          68 :         maMaxElementDimensions.Width() = aSizePixel.Width();
     472             :     }
     473             : 
     474         323 :     if (aSizePixel.Height() > maMaxElementDimensions.Height()) {
     475          34 :         maMaxElementDimensions.Height() = aSizePixel.Height();
     476             :     }
     477             : 
     478         646 :     SmElementPointer pElement(new SmElement(pNode, aElementSource, aHelpText));
     479         646 :     maElementList.push_back(pElement);
     480         323 : }
     481             : 
     482          17 : void SmElementsControl::setElementSetId(sal_uInt16 aSetId)
     483             : {
     484          17 :     maCurrentSetId = aSetId;
     485          17 :     maMaxElementDimensions = Size();
     486          17 :     build();
     487          17 : }
     488             : 
     489          17 : void SmElementsControl::addElements(const sal_uInt16 aElementsArray[][2], sal_uInt16 aElementsArraySize)
     490             : {
     491         374 :     for (sal_uInt16 i = 0; i < aElementsArraySize ; i++)
     492             :     {
     493         357 :         sal_uInt16 aElementId = aElementsArray[i][0];
     494         357 :         sal_uInt16 aElementIdHelp = aElementsArray[i][1];
     495         357 :         if (aElementId == 0xFFFF) {
     496          34 :             addSeparator();
     497             :         } else {
     498         323 :             if (aElementId == RID_NEWLINE)
     499           0 :                 addElement(OUString( "\xe2\x86\xb5", 3, RTL_TEXTENCODING_UTF8 ), SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     500         323 :             else if (aElementId == RID_SBLANK)
     501           0 :                 addElement("\"`\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     502         323 :             else if (aElementId == RID_BLANK)
     503           0 :                 addElement("\"~\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     504         323 :             else if (aElementId == RID_PHANTOMX)
     505           0 :                 addElement("\"" + SM_RESSTR(STR_HIDE) +"\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     506         323 :             else if (aElementId == RID_BOLDX)
     507           0 :                 addElement("bold B", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     508         323 :             else if (aElementId == RID_ITALX)
     509           0 :                 addElement("ital I", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     510         323 :             else if (aElementId == RID_SIZEXY)
     511           0 :                 addElement("\"" + SM_RESSTR(STR_SIZE) + "\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     512         323 :             else if (aElementId == RID_FONTXY)
     513           0 :                 addElement("\"" + SM_RESSTR(STR_FONT) + "\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     514         323 :             else if (aElementId == RID_COLORX_BLACK)
     515           0 :                 addElement("color black { \"" + SM_RESSTR(STR_BLACK) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     516         323 :             else if (aElementId == RID_COLORX_BLUE)
     517           0 :                 addElement("color blue { \"" + SM_RESSTR(STR_BLUE) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     518         323 :             else if (aElementId == RID_COLORX_GREEN)
     519           0 :                 addElement("color green { \"" + SM_RESSTR(STR_GREEN) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     520         323 :             else if (aElementId == RID_COLORX_RED)
     521           0 :                 addElement("color red { \"" + SM_RESSTR(STR_RED) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     522         323 :             else if (aElementId == RID_COLORX_CYAN)
     523           0 :                 addElement("color cyan { \"" + SM_RESSTR(STR_CYAN) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     524         323 :             else if (aElementId == RID_COLORX_MAGENTA)
     525           0 :                 addElement("color magenta { \"" + SM_RESSTR(STR_MAGENTA) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     526         323 :             else if (aElementId == RID_COLORX_YELLOW)
     527           0 :                 addElement("color yellow { \"" + SM_RESSTR(STR_YELLOW) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     528         323 :             else if (aElementId == RID_COLORX_GRAY)
     529           0 :                 addElement("color gray { \"" + SM_RESSTR(STR_GRAY) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     530         323 :             else if (aElementId == RID_COLORX_LIME)
     531           0 :                 addElement("color lime { \"" + SM_RESSTR(STR_LIME) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     532         323 :             else if (aElementId == RID_COLORX_MAROON)
     533           0 :                 addElement("color maroon { \"" + SM_RESSTR(STR_MAROON) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     534         323 :             else if (aElementId == RID_COLORX_NAVY)
     535           0 :                 addElement("color navy { \"" + SM_RESSTR(STR_NAVY) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     536         323 :             else if (aElementId == RID_COLORX_OLIVE)
     537           0 :                 addElement("color olive { \"" + SM_RESSTR(STR_OLIVE) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     538         323 :             else if (aElementId == RID_COLORX_PURPLE)
     539           0 :                 addElement("color purple { \"" + SM_RESSTR(STR_PURPLE) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     540         323 :             else if (aElementId == RID_COLORX_SILVER)
     541           0 :                 addElement("color silver { \"" + SM_RESSTR(STR_SILVER) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     542         323 :             else if (aElementId == RID_COLORX_TEAL)
     543           0 :                 addElement("color teal { \"" + SM_RESSTR(STR_TEAL) + "\" }", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     544         323 :             else if (aElementId == RID_ALIGNLX)
     545           0 :                 addElement("\"" + SM_RESSTR(STR_ALIGN_LEFT) + "\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     546         323 :             else if (aElementId == RID_ALIGNCX)
     547           0 :                 addElement("\"" + SM_RESSTR(STR_ALIGN_CENTER) + "\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     548         323 :             else if (aElementId == RID_ALIGNRX)
     549           0 :                 addElement("\"" + SM_RESSTR(STR_ALIGN_RIGHT) + "\"", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     550             : 
     551         323 :             else if (aElementId == RID_SLRPARENTX)
     552           0 :                 addElement("left ( binom{<?>}{<?>} right ) ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     553         323 :             else if (aElementId == RID_SLRBRACKETX)
     554           0 :                 addElement("left [ binom{<?>}{<?>} right ] ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     555         323 :             else if (aElementId == RID_SLRDBRACKETX)
     556           0 :                 addElement("left ldbracket binom{<?>}{<?>} right rdbracket ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     557         323 :             else if (aElementId == RID_SLRBRACEX)
     558           0 :                 addElement("left lbrace binom{<?>}{<?>} right rbrace ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     559         323 :             else if (aElementId == RID_SLRANGLEX)
     560           0 :                 addElement("left langle binom{<?>}{<?>} right rangle ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     561         323 :             else if (aElementId == RID_SLRCEILX)
     562           0 :                 addElement("left lceil binom{<?>}{<?>} right rceil ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     563         323 :             else if (aElementId == RID_SLRFLOORX)
     564           0 :                 addElement("left lfloor binom{<?>}{<?>} right rfloor ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     565             : 
     566         323 :             else if (aElementId == RID_SLRLINEX)
     567           0 :                 addElement("left lline binom{<?>}{<?>} right rline ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     568         323 :             else if (aElementId == RID_SLRDLINEX)
     569           0 :                 addElement("left ldline binom{<?>}{<?>} right rdline ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     570         323 :             else if (aElementId == RID_SLMRANGLEXY)
     571           0 :                 addElement("left langle binom{<?>}{<?>} mline binom{<?>}{<?>} right rangle ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     572             : 
     573         323 :             else if (aElementId == RID_XOVERBRACEY)
     574           0 :                 addElement("{<?><?><?>} overbrace {<?>} ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     575         323 :             else if (aElementId == RID_XUNDERBRACEY)
     576           0 :                 addElement("{<?><?><?>} underbrace {<?>} ", SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     577             :             else
     578         323 :                 addElement(SM_RESSTR(aElementId), SM_RESSTR(aElementId), SM_RESSTR(aElementIdHelp));
     579             :         }
     580             :     }
     581          17 : }
     582             : 
     583          17 : void SmElementsControl::build()
     584             : {
     585          17 :     maElementList.clear();
     586             : 
     587          17 :     switch(maCurrentSetId)
     588             :     {
     589             :         // we need to divide by 2 because of the matrix of two dimensions
     590             :         case RID_CATEGORY_UNARY_BINARY_OPERATORS:
     591          17 :             addElements(aUnaryBinaryOperatorsList, SAL_N_ELEMENTS(aUnaryBinaryOperatorsList));
     592          17 :         break;
     593             :         case RID_CATEGORY_RELATIONS:
     594           0 :             addElements(aRelationsList, SAL_N_ELEMENTS(aRelationsList));
     595           0 :         break;
     596             :         case RID_CATEGORY_SET_OPERATIONS:
     597           0 :             addElements(aSetOperations, SAL_N_ELEMENTS(aSetOperations));
     598           0 :         break;
     599             :         case RID_CATEGORY_FUNCTIONS:
     600           0 :             addElements(aFunctions, SAL_N_ELEMENTS(aFunctions));
     601           0 :         break;
     602             :         case RID_CATEGORY_OPERATORS:
     603           0 :             addElements(aOperators, SAL_N_ELEMENTS(aOperators));
     604           0 :         break;
     605             :         case RID_CATEGORY_ATTRIBUTES:
     606           0 :             addElements(aAttributes, SAL_N_ELEMENTS(aAttributes));
     607           0 :         break;
     608             :         case RID_CATEGORY_BRACKETS:
     609           0 :             addElements(aBrackets, SAL_N_ELEMENTS(aBrackets));
     610           0 :         break;
     611             :         case RID_CATEGORY_FORMATS:
     612           0 :             addElements(aFormats, SAL_N_ELEMENTS(aFormats));
     613           0 :         break;
     614             :         case RID_CATEGORY_OTHERS:
     615           0 :             addElements(aOthers, SAL_N_ELEMENTS(aOthers));
     616           0 :         break;
     617             :         case RID_CATEGORY_EXAMPLES:
     618             :         {
     619           0 :             OUString aEquation = "C=%pi cdot d = 2 cdot %pi cdot r";
     620           0 :             addElement(aEquation, aEquation, "");
     621           0 :             aEquation = "E=mc^2";
     622           0 :             addElement(aEquation, aEquation, "");
     623           0 :             aEquation = "a^2 + b^2 = c^2";
     624           0 :             addElement(aEquation, aEquation, "");
     625           0 :             aEquation = "f ( x ) = sum from { { i = 0 } } to { infinity } { {f^{(i)}(0)} over {i!} x^i}";
     626           0 :             addElement(aEquation, aEquation, "");
     627           0 :             aEquation = "f ( x ) = {1} over {%sigma sqrt{2%pi} }e^-{{(x-%mu)^2} over {2%sigma^2}}";
     628           0 :             addElement(aEquation, aEquation, "");
     629             :         }
     630           0 :         break;
     631             :     }
     632          17 :     Invalidate();
     633          17 : }
     634             : 
     635          50 : Size SmElementsControl::GetOptimalSize() const
     636             : {
     637          50 :     return LogicToPixel(Size(100, 100), MapMode(MAP_APPFONT));
     638             : }
     639             : 
     640             : const sal_uInt16 SmElementsDockingWindow::aCategories[] = {
     641             :     RID_CATEGORY_UNARY_BINARY_OPERATORS,
     642             :     RID_CATEGORY_RELATIONS,
     643             :     RID_CATEGORY_SET_OPERATIONS,
     644             :     RID_CATEGORY_FUNCTIONS,
     645             :     RID_CATEGORY_OPERATORS,
     646             :     RID_CATEGORY_ATTRIBUTES,
     647             :     RID_CATEGORY_BRACKETS,
     648             :     RID_CATEGORY_FORMATS,
     649             :     RID_CATEGORY_OTHERS,
     650             :     RID_CATEGORY_EXAMPLES
     651             : };
     652             : 
     653          17 : SmElementsDockingWindow::SmElementsDockingWindow(SfxBindings* pInputBindings, SfxChildWindow* pChildWindow, vcl::Window* pParent) :
     654             :     SfxDockingWindow(pInputBindings, pChildWindow, pParent, "DockingElements",
     655          17 :         "modules/smath/ui/dockingelements.ui")
     656             : {
     657          17 :     mpElementsControl = VclPtr<SmElementsControl>::Create(get<vcl::Window>("box"));
     658          17 :     mpElementsControl->set_hexpand(true);
     659          17 :     mpElementsControl->set_vexpand(true);
     660          17 :     mpElementsControl->Show();
     661          17 :     get(mpElementListBox, "listbox");
     662             : 
     663          17 :     mpElementsControl->SetBorderStyle( WindowBorderStyle::MONO );
     664             : 
     665          17 :     mpElementListBox->SetDropDownLineCount( SAL_N_ELEMENTS(aCategories) );
     666             : 
     667         187 :     for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aCategories) ; i++)
     668             :     {
     669         170 :         mpElementListBox->InsertEntry(SM_RESSTR(aCategories[i]));
     670             :     }
     671             : 
     672          17 :     mpElementListBox->SetSelectHdl(LINK(this, SmElementsDockingWindow, ElementSelectedHandle));
     673          17 :     mpElementListBox->SelectEntry(SM_RESSTR(RID_CATEGORY_UNARY_BINARY_OPERATORS));
     674             : 
     675          17 :     mpElementsControl->SetBackground( Color( COL_WHITE ) );
     676          17 :     mpElementsControl->SetTextColor( Color( COL_BLACK ) );
     677          17 :     mpElementsControl->setElementSetId(RID_CATEGORY_UNARY_BINARY_OPERATORS);
     678          17 :     mpElementsControl->selectedSignal.connect( boost::bind( &SmElementsDockingWindow::SelectClickHandler, this, _1 ) );
     679          17 : }
     680             : 
     681           0 : SmElementsDockingWindow::~SmElementsDockingWindow ()
     682             : {
     683           0 :     disposeOnce();
     684           0 : }
     685             : 
     686          17 : void SmElementsDockingWindow::dispose()
     687             : {
     688          17 :     mpElementsControl.disposeAndClear();
     689          17 :     mpElementListBox.clear();
     690          17 :     SfxDockingWindow::dispose();
     691          17 : }
     692             : 
     693           0 : void SmElementsDockingWindow::ToggleFloatingMode()
     694             : {
     695           0 :     SfxDockingWindow::ToggleFloatingMode();
     696             : 
     697           0 :     if (GetFloatingWindow())
     698           0 :         GetFloatingWindow()->SetMinOutputSizePixel( Size(100, 100) );
     699             : 
     700           0 :     Invalidate();
     701           0 : }
     702             : 
     703           0 : void SmElementsDockingWindow::EndDocking( const Rectangle& rReactangle, bool bFloatMode)
     704             : {
     705           0 :     SfxDockingWindow::EndDocking(rReactangle, bFloatMode);
     706           0 :     bool bVertical = ( GetAlignment() == SfxChildAlignment::TOP || GetAlignment() == SfxChildAlignment::BOTTOM );
     707           0 :     mpElementsControl->setVerticalMode(bVertical);
     708           0 : }
     709             : 
     710           0 : void SmElementsDockingWindow::SelectClickHandler( SmElement* pElement )
     711             : {
     712           0 :     SmViewShell* pViewSh = GetView();
     713             : 
     714           0 :     if (pViewSh)
     715             :     {
     716             :         pViewSh->GetViewFrame()->GetDispatcher()->Execute(
     717             :             SID_INSERTCOMMANDTEXT, SfxCallMode::RECORD,
     718           0 :             new SfxStringItem(SID_INSERTCOMMANDTEXT, pElement->getText()), 0L);
     719             :     }
     720           0 : }
     721             : 
     722           0 : IMPL_LINK( SmElementsDockingWindow, ElementSelectedHandle, ListBox*, pList)
     723             : {
     724           0 :     for (sal_uInt16 i = 0; i < SAL_N_ELEMENTS(aCategories) ; i++)
     725             :     {
     726           0 :         sal_uInt16 aCurrentCategory = aCategories[i];
     727           0 :         OUString aCurrentCategoryString = SM_RESSTR(aCurrentCategory);
     728           0 :         if (aCurrentCategoryString == pList->GetSelectEntry())
     729             :         {
     730           0 :             mpElementsControl->setElementSetId(aCurrentCategory);
     731           0 :             return 0;
     732             :         }
     733           0 :     }
     734           0 :     return 0;
     735             : }
     736             : 
     737           0 : SmViewShell* SmElementsDockingWindow::GetView()
     738             : {
     739           0 :     SfxViewShell* pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell();
     740           0 :     return PTR_CAST(SmViewShell, pView);
     741             : }
     742             : 
     743         119 : void SmElementsDockingWindow::Resize()
     744             : {
     745         119 :     bool bVertical = ( GetAlignment() == SfxChildAlignment::TOP || GetAlignment() == SfxChildAlignment::BOTTOM );
     746         119 :     mpElementsControl->setVerticalMode(bVertical);
     747             : 
     748         119 :     SfxDockingWindow::Resize();
     749         119 :     Invalidate();
     750         119 : }
     751             : 
     752          62 : SFX_IMPL_DOCKINGWINDOW_WITHID(SmElementsDockingWindowWrapper, SID_ELEMENTSDOCKINGWINDOW);
     753             : 
     754          17 : SmElementsDockingWindowWrapper::SmElementsDockingWindowWrapper(
     755             :                             vcl::Window *pParentWindow, sal_uInt16 nId,
     756             :                             SfxBindings *pBindings, SfxChildWinInfo *pInfo) :
     757          17 :     SfxChildWindow(pParentWindow, nId)
     758             : {
     759          17 :     VclPtrInstance<SmElementsDockingWindow> pDialog(pBindings, this, pParentWindow);
     760          17 :     pWindow.reset(pDialog);
     761          17 :     pDialog->setDeferredProperties();
     762          17 :     pDialog->SetPosSizePixel(Point(0, 0), Size(300, 0));
     763          17 :     pDialog->Show();
     764             : 
     765          17 :     eChildAlignment = SfxChildAlignment::LEFT;
     766             : 
     767          17 :     pDialog->Initialize( pInfo );
     768          17 : }
     769             : 
     770          34 : SmElementsDockingWindowWrapper::~SmElementsDockingWindowWrapper()
     771             : {
     772          76 : }
     773             : 
     774             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11