sd/source/ui/inc/ViewShellBase.hxx | 4 ++++ sd/source/ui/view/ViewShellBase.cxx | 18 ++++++++++++++++++ svx/source/dialog/fntctrl.cxx | 18 ++++++++---------- 3 files changed, 30 insertions(+), 10 deletions(-)
New commits: commit 3d1f4649ee72dd85e1d994ac2bdccc3147830bbd Author: Michael Stahl <[email protected]> Date: Sun Oct 14 21:10:38 2012 +0200 FontPrevWin_Impl::CheckScript(): assert that there is text: If there is no preview text here then aTextWidth will have no entries and we crash when writing to the non-existing first element. aText should come from the current SfxViewShell, from the font name (unless that is ambiguous, e.g. a selection of text with multiple fonts), or the Window text (Window::GetText(), whatever that is). diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index c09f3bf..cc775a5 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -176,7 +176,6 @@ class FontPrevWin_Impl bool m_bCTLEnabled; - void _CheckScript(); public: inline FontPrevWin_Impl() : pPrinter( NULL ), bDelPrinter( sal_False ), @@ -213,12 +212,6 @@ public: // sets the 100%-Font-Widths }; -void FontPrevWin_Impl::CheckScript() -{ - if( aText != aScriptText ) - _CheckScript(); -} - inline void FontPrevWin_Impl::Invalidate100PercentFontWidth() { n100PercentFontWidth = n100PercentFontWidthCJK = n100PercentFontWidthCTL = -1; @@ -237,15 +230,19 @@ inline sal_Bool FontPrevWin_Impl::Is100PercentFontWidthValid() const // class FontPrevWin_Impl ----------------------------------------------- /* - * void FontPrevWin_Impl::_CheckScript() * evalutates the scripttypes of the actual string. * Afterwards the positions of script change are notified in aScriptChg, * the scripttypes in aScriptType. * The aTextWidth array will be filled with zero. */ - -void FontPrevWin_Impl::_CheckScript() +void FontPrevWin_Impl::CheckScript() { + assert(aText.Len()); // must have a preview text here! + if (aText == aScriptText) + { + return; // already initialized + } + aScriptText = aText; aScriptChg.clear(); @@ -258,6 +255,7 @@ void FontPrevWin_Impl::_CheckScript() xBreak = Reference< XBreakIterator >(xMSF->createInstance( ::rtl::OUString("com.sun.star.i18n.BreakIterator") ),UNO_QUERY); } + assert(xBreak.is()); // no can do without breakiter if( xBreak.is() ) { sal_uInt16 nScript = xBreak->getScriptType( aText, 0 ); commit 86b6bf6e53c234e3df951ebb08513b0d4fc47a14 Author: Michael Stahl <[email protected]> Date: Sun Oct 14 21:05:15 2012 +0200 sd: fix crash in character format dialog: When text with different fonts is selected in Draw or Impress, the character format dialog crashes, because (among other things) the selected text is not returned by SfxViewShell::GetSelectionText(). Crash was observed both with GraphicViewShellBase and ImpressViewShellBase as current shell. Override that method in sd::ViewShellBase to forward to a main shell that happens to be a DrawViewShell which is not actually a SfxViewShell but happens to implement GetSelectionText() for mysterious reasons. diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx index 089368a..7d1e7d5 100644 --- a/sd/source/ui/inc/ViewShellBase.hxx +++ b/sd/source/ui/inc/ViewShellBase.hxx @@ -123,6 +123,10 @@ public: */ virtual void GetState (SfxItemSet& rSet); + /* override these from SfxViewShell */ + virtual String GetSelectionText(sal_Bool); + virtual sal_Bool HasSelection(sal_Bool) const; + SvBorder GetBorder (bool bOuterResize); virtual void InnerResizePixel (const Point& rOrigin, const Size& rSize); virtual void OuterResizePixel (const Point& rOrigin, const Size& rSize); diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx index 7648841..d5d1ded 100644 --- a/sd/source/ui/view/ViewShellBase.cxx +++ b/sd/source/ui/view/ViewShellBase.cxx @@ -489,7 +489,25 @@ void ViewShellBase::InitializeFramework (void) } +String ViewShellBase::GetSelectionText(sal_Bool bCompleteWords) +{ + ::boost::shared_ptr<ViewShell> const pMainShell(GetMainViewShell()); + DrawViewShell *const pDrawViewShell( + dynamic_cast<DrawViewShell*>(pMainShell.get())); + return (pDrawViewShell) + ? pDrawViewShell->GetSelectionText(bCompleteWords) + : SfxViewShell::GetSelectionText(bCompleteWords); +} +sal_Bool ViewShellBase::HasSelection(sal_Bool bText) const +{ + ::boost::shared_ptr<ViewShell> const pMainShell(GetMainViewShell()); + DrawViewShell *const pDrawViewShell( + dynamic_cast<DrawViewShell*>(pMainShell.get())); + return (pDrawViewShell) + ? pDrawViewShell->HasSelection(bText) + : SfxViewShell::HasSelection(bText); +} void ViewShellBase::InnerResizePixel (const Point& rOrigin, const Size &rSize) { _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
